home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / doc / unix / equel.doc < prev    next >
Encoding:
Text File  |  1992-11-19  |  13.0 KB  |  296 lines

  1.  
  2.  
  3.  
  4.  
  5.      EQUEL(UNIX)                  3/14/79                  EQUEL(UNIX)
  6.  
  7.  
  8.  
  9.      NAME
  10.           equel - Embedded QUEL interface to C
  11.  
  12.      SYNOPSIS
  13.           _e_q_u_e_l [ -_d ] [ -_f ] [ -_r ] file.q ...
  14.  
  15.      DESCRIPTION
  16.           _E_q_u_e_l provides the user with a  method  of  interfacing  the
  17.           general  purpose programming language ``C'' with INGRES.  It
  18.           consists of the EQUEL pre-compiler and the EQUEL runtime li-
  19.           brary.
  20.  
  21.           _C_o_m_p_i_l_a_t_i_o_n
  22.  
  23.           The precompiler is invoked with the statement:
  24.  
  25.                _e_q_u_e_l [<flags>] file1.q [<flags>] file2.q ...
  26.  
  27.           where file_n.q are the source input file  names,  which  must
  28.           end with ._q.  The output is written to the file ``file_n.c''.
  29.           As many files as wished may be specified.
  30.           The flags that may be used are:
  31.  
  32.           -d   Generate code to print source  listing  file  name  and
  33.                line  number  when a run-time error occurs. This can be
  34.                useful for debugging, but takes up process space.   De-
  35.                faults to off.
  36.  
  37.           -f   Forces code to be on the same line in the  output  file
  38.                as it is in the input file to ease interpreting C diag-
  39.                nostic messages.  EQUEL will usually try to get  all  C
  40.                code lines in the output file on the same lines as they
  41.                were in the input file.  Sometimes  it  must  break  up
  42.                queries into several lines to avoid C-preprocessor line
  43.                overflows, possibly  moving  some  C  code  ahead  some
  44.                lines.  With the -_f flag specified this will never hap-
  45.                pen and, though the line buffer may overflow,  C  lines
  46.                will  be on the right line.  This is useful for finding
  47.                the line in the source file that C error diagnostics on
  48.                the output file refer to.
  49.  
  50.           -r   Resets flags to default values.  Used to supress  other
  51.                flags for some of the files in the argument list.
  52.  
  53.           The output files may than be compiled using the C compiler:
  54.  
  55.                _c_c file1.c file2.c ... -_l_q
  56.  
  57.           The -_l_q requests the use of the EQUEL object library.
  58.  
  59.           All EQUEL routines and globals  begin  with  the  characters
  60.           "II",  and  so  all globals variables and procedure names of
  61.           the form II_x_x_x are reserved for use by EQUEL and  should  be
  62.           avoided by EQUEL users.
  63.  
  64.           _B_a_s_i_c _S_y_n_t_a_x
  65.  
  66.           EQUEL commands are indicated by lines  which  begin  with  a
  67.           double  pound  sign (``##'').  Other lines are simply copied
  68.           as is.  All normal INGRES commands may be used in EQUEL  and
  69.           have  the  same effect as if invoked through the interactive
  70.           terminal monitor.  Only retrieve commands with no result re-
  71.           lation specified have a different syntax and meaning.
  72.  
  73.           The format of retrieve without a result relation is modified
  74.           to:
  75.  
  76.                ## retrieve (C-variable = a_fcn { , C-variable =  a_fcn
  77.                } )
  78.  
  79.           optionally followed (immediately) by:
  80.  
  81.                ##      [ _w_h_e_r_e _q_u_a_l ]
  82.                ## {
  83.                        /* C-code */
  84.                ## }
  85.  
  86.           This statement causes the ``C-code'' to be executed once for
  87.           each tuple retrieved, with the ``C-variable''s set appropri-
  88.           ately.  Numeric values of any type are converted  as  neces-
  89.           sary.   No  conversion is done between numeric and character
  90.           values.  (The normal INGRES _a_s_c_i_i function may be  used  for
  91.           this purpose.)
  92.  
  93.           Also, the following EQUEL commands are permitted.
  94.  
  95.           ## _i_n_g_r_e_s [ingres flags] data_base_name
  96.                This command starts INGRES  running,  and  directs  all
  97.                dynamically   following   queries   to   the   database
  98.                _d_a_t_a__b_a_s_e__n_a_m_e.  It is a run-time error to execute this
  99.                command  twice  without  an intervening ``## exit'', as
  100.                well as to issue queries while an ``## ingres''  state-
  101.                ment is not in effect.  Each flag should be enclosed in
  102.                quotes to avoid confusion in the EQUEL parser:
  103.  
  104.                        ## ingres "-f4f10.2" "-i212" demo
  105.  
  106.           ## _e_x_i_t
  107.                Exit simply exits from INGRES.  It is equivalent to the
  108.                _\_q command to the teletype monitor.
  109.  
  110.           _P_a_r_a_m_e_t_r_i_z_e_d _Q_u_e_l _S_t_a_t_e_m_e_n_t_s
  111.  
  112.           Quel statements with target lists may  be  ``parametrized''.
  113.           This  is  indicated by preceding the statement with the key-
  114.           word ``param''.  The target list of a parametrized statement
  115.           has the form:
  116.  
  117.                   ( _t_l__v_a_r, _a_r_g_v )
  118.  
  119.           where _t_l__v_a_r is taken to be a string  pointer  at  execution
  120.           time  (it  may be a string constant) and interpreted as fol-
  121.           lows.  For any parametrized EQUEL  statement  except  a  re-
  122.           trieve without a result relation (no ``into rel'') (i.e. ap-
  123.           pend, copy,  create,  replace,  retrieve  into)  the  string
  124.           _t_l__v_a_r  is  taken  to  be  a regular target list except that
  125.           wherever a `%' appears a valid INGRES type (f4, f8, i2,  i4,
  126.           c)  is expected to follow.  Each of these is replaced by the
  127.           value of the corresponding entry into _a_r_g_v (starting  at  0)
  128.           which  is  interpreted  to be a pointer to a variable of the
  129.           type indicated by the `%' sequence.  Neither  _a_r_g_v  nor  the
  130.           variables which it points to need be declared to EQUEL.  For
  131.           example:
  132.  
  133.                char    *argv[10];
  134.  
  135.                        argv[0] = &double_var;
  136.                        argv[1] = &int_var;
  137.                ##      param append to rel
  138.                ##              ("dom1 = %f8, dom2 = %i2", argv)
  139.                ##      /* to escape the "%<ingres_type>" mechanism use "%%" */
  140.                ##      /* This places a single `%' in the string. */
  141.  
  142.           On a retrieve to C-variables, within _t_l__v_a_r, instead of  the
  143.           C-variable  to  retrieve into, the same `%' escape sequences
  144.           are used to denote the type of the corresponding argv  entry
  145.           into which the value will be retrieved.
  146.  
  147.           The qualification of any query may be replaced by  a  string
  148.           valued  variable,  whose contents is interpreted at run time
  149.           as the text of the qualification.
  150.  
  151.           The _c_o_p_y statement may also be parametrized.   The  form  of
  152.           the parametrized _c_o_p_y is analogous to the other parametrized
  153.           statements: the target list may be parametrized in the  same
  154.           manner  as  the  _a_p_p_e_n_d  statements,  and  furthermore,  the
  155.           _f_r_o_m/_i_n_t_o keyword may be replaced by a string  valued  vari-
  156.           able whose content at run time should be _i_n_t_o or _f_r_o_m.
  157.  
  158.           _D_e_c_l_a_r_a_t_i_o_n_s
  159.  
  160.           Any valid C variable declaration on a line beginning with  a
  161.           ``##''  declares  a  C-variable that may be used in an EQUEL
  162.           statement and as a normal variable.  All variables  must  be
  163.           declared  before being used.  Anywhere a constant may appear
  164.           in an INGRES command, a C-variable may appear.  The value of
  165.           the C-variable is substituted at execution time.
  166.  
  167.           Neither nested structures nor variables of type _c_h_a_r (as op-
  168.           posed  to  pointer  to  char  or array of char) are allowed.
  169.           Furthermore, there are two restrictions in the way variables
  170.           are referenced within EQUEL statements.  All variable usages
  171.           must be dereferenced  and/or  subscripted  (for  arrays  and
  172.           pointers),  or  selected  (for structure variables) to yield
  173.           lvalues (scalar values).  _C_h_a_r variables are used  by  EQUEL
  174.           as  a means to use _s_t_r_i_n_g_s.  Therefore when using a _c_h_a_r ar-
  175.           ray or pointer it must be dereferenced only to a ``_c_h_a_r *''.
  176.           Also,  variables  may  not  have parentheses in their refer-
  177.           ences.  For example:
  178.  
  179.                ## struct xxx
  180.                ## {
  181.                        int     i;
  182.                ##      int     *ip;
  183.                ## }    **struct_var;
  184.  
  185.                /* not allowed */
  186.                ##      delete p where p.ifield = *(*struct_var)->ip
  187.  
  188.                /* allowed */
  189.                ##      delete p where p.ifield = *struct_var[0]->ip
  190.  
  191.           C variables declared to EQUEL have either  global  or  local
  192.           scope.   Their scope is local if their declaration is within
  193.           a free (not bound to a retrieve) block  declared  to  EQUEL.
  194.           For example:
  195.  
  196.                /* globals scope variable */
  197.                ## int  Gint;
  198.  
  199.                func(i)
  200.                int     i;
  201.                ## {
  202.                        /* local scope variable */
  203.                ##      int     *gintp;
  204.                        ...
  205.                ## }
  206.  
  207.           If a variable of one of the char types is used  almost  any-
  208.           where  in an EQUEL statement the content of that variable is
  209.           used at run time.  For example:
  210.  
  211.                ##      char    *dbname[MAXDATABASES + 1];
  212.                        int     current_db;
  213.                        dbname[current_db] = "demo";
  214.                ##      ingres dbname[current_db]
  215.  
  216.           will cause INGRES to be invoked  with  data  base  ``demo''.
  217.           However,  if  a variable's name is to be used as a constant,
  218.           then the non-referencing operator `#' should be  used.   For
  219.           example:
  220.  
  221.                ## char *demo;
  222.  
  223.                        demo = "my_database";
  224.  
  225.                        /* ingres -d my_database */
  226.                ##      ingres "-d" demo
  227.  
  228.                        /* ingres -d demo */
  229.                ##      ingres "-d" #demo
  230.  
  231.           The C-preprocessor's #include feature may be used  on  files
  232.           containing  equel statements and declarations if these files
  233.           are named _a_n_y_t_h_i_n_g._q._h.  An EQUEL processed version  of  the
  234.           file, which will be #included by the C-preprocessor, is left
  235.           in _a_n_y_t_h_i_n_g._c._h.
  236.  
  237.           _E_r_r_o_r_s _a_n_d _I_n_t_e_r_r_u_p_t_s
  238.  
  239.           INGRES and run-time EQUEL errors cause the  routine  _I_I_e_r_r_o_r
  240.           to  be  called,  with the error number and the parameters to
  241.           the error in an array of string pointers as in a C  language
  242.           main  routine.   The  error  message  will  be looked up and
  243.           printed. before printing  the  error  message,  the  routine
  244.           (*IIprint_err)()  is  called  with  the  error  number  that
  245.           ocurred  as  its  single   argument.   The   error   message
  246.           corresponding    to    the    error   number   returned   by
  247.           (*IIprint_err)()  will  be  printed.    Printing   will   be
  248.           supressed if (*IIprint_err)() returns 0.  IIprint_err may be
  249.           reassigned to, and is useful for programs which  map  INGRES
  250.           errors  into  their own error messages.  In addition, if the
  251.           ``-_d'' flag was set the file name and line number of the er-
  252.           ror  will be printed.  The user may write an IIerror routine
  253.           to do other tasks as long as the setting of IIerrflag is not
  254.           modified as this is used to exit retrieves correctly.
  255.  
  256.           Interrupts are caught by equel if they  are  not  being  ig-
  257.           nored.  This insures that the rest of INGRES is in sync with
  258.           the EQUEL process.  There is a  function  pointer,  IIinter-
  259.           rupt, which points to a function to call after the interrupt
  260.           is caught. The user may use this to service  the  interrupt.
  261.           It  is  initialized to "exit()" and is called with -1 as its
  262.           argument.  For example:
  263.  
  264.                   extern int (*IIinterrupt)();
  265.                   extern reset();
  266.  
  267.                   setexit();
  268.                   IIinterrupt = reset;
  269.                   mainloop();
  270.  
  271.           To ignore interrupts, signal() should be called  before  the
  272.           ## ingres satatement is executed.
  273.  
  274.      FILES
  275.           .../files/error8_*
  276.                Can be used  by  the  user  to  decipher  INGRES  error
  277.                numbers.
  278.           .../lib/libq.a
  279.                Run time library.
  280.  
  281.      SEE ALSO
  282.           .../doc/other/equeltut.q, C reference manual,  ingres(UNIX),
  283.           quel(QUEL)
  284.  
  285.      BUGS
  286.           The C-code embedded in the tuple-by-tuple retrieve operation
  287.           may  not contain additional QUEL statements or recursive in-
  288.           vocations of INGRES.
  289.  
  290.           There is no way to specify an _i_1 format C-variable.
  291.  
  292.           Includes of an equel  file  within  a  parameterized  target
  293.           list,  or within a C variable's array subscription brackets,
  294.           isn't done correctly.
  295.  
  296.